package com.yijiu.response;

import org.json.JSONException;
import org.json.JSONObject;

import com.yijiu.network.Response;

/**
 * 请求佣金详情的相应
 * 
 * @author TangChao
 */
public class RequestBrokerageDetailResponse extends Response
{
	public String investorName;
	public long investMoney;
	public long investData;
	public int inCome;
	public String projectName;
	public long needMoney;
	public String yield;
	public int deadline;
	public String deadlineUnit;
	public String payType;
	public long startTime;
	public long endTime;
	
	public String guaranteeName;
	public String guaranteeStatement;
	public String guaranteeAudit;
	public String guaranteeLicenseUrl;
	
	@Override
	protected void jsonToObject()
	{
		try
		{
			JSONObject jsonObjectResult = reposonJson.getJSONObject("result");
			JSONObject jsonObjectDataMap = jsonObjectResult.getJSONObject("dataMap");
			JSONObject jsonObjectLoanItem = jsonObjectDataMap.getJSONObject("loanItem");
			JSONObject josnObjectTrade = jsonObjectDataMap.getJSONObject("tradeItem");
			investorName = jsonObjectLoanItem.optString("loanName");
			needMoney = jsonObjectLoanItem.optLong("loanAmount");
			yield = jsonObjectResult.optString("interestRate");
			deadline = jsonObjectLoanItem.optInt("timeLimit");
			deadlineUnit = jsonObjectLoanItem.optString("timeLimitUnit");
			
			guaranteeName = jsonObjectLoanItem.optString("guaranteeName");
			guaranteeStatement = jsonObjectLoanItem.optString("guaranteeStatement");
			guaranteeAudit = jsonObjectLoanItem.optString("guaranteeAudit");
			guaranteeLicenseUrl = jsonObjectLoanItem.optString("guaranteeLicenseUrl");
			
			JSONObject jsonObjectTrade = jsonObjectDataMap.getJSONObject("trade");
			startTime = jsonObjectTrade.optLong("effectiveDateTime");
			endTime = jsonObjectTrade.optLong("expireDateTime");
			JSONObject jsonObjectJjrTrade = jsonObjectDataMap.getJSONObject("jjrTrade");
			inCome = jsonObjectJjrTrade.optInt("amount");
			JSONObject jsonObjectTradeItem = jsonObjectDataMap.getJSONObject("tradeItem");
			investData = jsonObjectTradeItem.optLong("date");
			investMoney = josnObjectTrade.optLong("amount");
			investorName = jsonObjectJjrTrade.optString("investorRealName");
			projectName = jsonObjectLoanItem.optString("loanName");
		}
		catch (JSONException e)
		{
			e.printStackTrace();
		}
	}
}
